package adapter.mgq.adapter;

/**
 * @author MaGuangQi
 * @description 适配器类.实现媒体播放接口, 同时持有AdvancedMediaPlayer
 * @date 2020-06-06 23:44
 **/
public class MediaAdapter implements MediaPlayer {
    private AdvancedMediaPlayer advancedMediaPlayer;

    /**
    * 方法描述: 有参构造
    * @param  audioType 声音类型
    * @return void
    */
    public MediaAdapter(String audioType) {
        if ("vlc".equals(audioType)) {
            advancedMediaPlayer = new VlcPlayer();
        } else if ("mp4".equals(audioType)) {
            advancedMediaPlayer = new Mp4Player();
        }
    }

    @Override
    public void play(String audioType, String filename) {
        if ("vlc".equals(audioType)) {
            advancedMediaPlayer.playVlc(filename);
        }else if ("mp4".equals(audioType)) {
            advancedMediaPlayer.playMp4(filename);
        }
    }
}
